// app.js
import { marketRole, farmerRole, workerRole } from "./config/tabBarConfig"
import { initWxFn } from "./utils/wxfn"
App({
  onLaunch() {
    initWxFn()
    let userInfo = wx.getStorageSync("userInfo");
    this.globalData.userInfo = (userInfo && JSON.parse(userInfo)) || null;
  },
  globalData: {
    userInfo: null,
    list: []
  },
  switchTabWithRole: function (role) {
    //交易市场
    if (role == 1) {
      this.globalData.list = marketRole
      if (this.changeTabbarCallback) {
        this.changeTabbarCallback(this.globalData.list)
      }
      wx.switchTab({
        url: '/pages/dashboard/index/index',
      })
    } else if (role == 2) {
      // 农户
      this.globalData.list = farmerRole
      if (this.changeTabbarCallback) {
        this.changeTabbarCallback(this.globalData.list)
      }
      wx.switchTab({
        url: '/pages/dashboard/index/index',
      })
    } else if (role == 3) {
      // 小工
      this.globalData.list = workerRole
      if (this.changeTabbarCallback) {
        this.changeTabbarCallback(this.globalData.list)
      }
      wx.switchTab({
        url: '/pages/order/index/index',
      })
    }
  }
})